"""

@name:python学习
@author:yuki
@projectname:起步

"""
import random
from time import sleep

class role:
    hp = 100
    def __init__(self,Name,Sex,Equipment):
        self.Name = Name
        self.Sex = Sex
        self.Equipment = Equipment
    def hit(self):
        if self.Equipment > 0:
            self.hp -= 5
            self.Equipment -= 1
            print(f"{self.Name} have suffered 5 damage and equipment durable reduce 1")
        elif self.Equipment == 0:
            self.hp -= 10
            print("you have suffered 5 damage")

class Room:
    room_list = []
    def progress(percent=0, width=30):
        left = width * percent // 100
        right = width - left
        print('\r[', '#' * left, ' ' * right, ']',
              f' {percent:.0f}%',
              sep='', end='', flush=True)
    def add(self,role):
        if len(self.room_list) == 1:
            print(f"{role.name} hava enter the room and you can pk now")
            self.room_list.append(role)
        elif len(self.room_list) == 0:
            print(f"{role.name} have enter the room and you have to wait for other one")
        elif len(self.room_list) == 2:
            print("room is full")

    def pk(self):
        player_one = self.room_list[0]
        player_two = self.room_list[1]
        while True:
            if player_one.hp > 0 and player_two.hp > 0:
                a = random.randint(1,10)
                b = random.randint(1,10)
                if a > b:
                    for i in range(101):
                        self.progress(i)
                        sleep(0.1)
                    player_one.hit()
                elif a < b:
                    for i in range(101):
                        self.progress(i)
                        sleep(0.1)
                    player_two.hit()
                elif a == b:
                    for i in range(101):
                        self.progress(i)
                        sleep(0.1)
                    print("draw")
            elif player_one <= 0 or player_two <= 0:
                if player_one.hp <= 0:
                    print(f"{player_one} lose")
                    break
                elif player_two.h <= 0:
                    print(f"{player_two} lose")
                    break


def main():
    a_name = input("please input your name(a):")
    a_sex = input("please input your sex(a):")
    a_armor = random.randint(1,5)
    b_name = input("please input your name(b):")
    b_sex = input("please input your sex(b):")
    b_armor = random.randint(1,5)

# if __name__ == '__main__':
#     main()
#     print(a_name)
#     A = role(a_name, a_sex, a_armor)
#     B = role(b_name, b_sex, b_armor)
#     Room.add(A.Name)
#     Room.add(B.Name)
li=role('小李',"M",10)
xi=role('小洗',"w",10)
room=Room
room.add(li)
